package aclass.rocksea.com.database.db;

import android.content.Context;
import android.os.Environment;

import com.litesuits.orm.LiteOrm;
import com.litesuits.orm.db.DataBaseConfig;

import java.util.ArrayList;

/**
 * Created by Mrw on 2017/7/5.
 *
 */

public class NoteDbHelper {
    private static LiteOrm mNoteDb;
    private static NoteDbHelper mNoteDbHelper;
    private NoteDbHelper(Context context) {
        //初始化数据库
        DataBaseConfig config = new DataBaseConfig(context);
        //config.dbName = Environment.getExternalStorageDirectory().getPath()+"/DataBase/db/Note.db";
        config.dbName = "Note.db";
        config.dbVersion = 1;
        mNoteDb = LiteOrm.newCascadeInstance(config);
    }
    public static NoteDbHelper getInstance(Context context){
        if (mNoteDb==null){
            synchronized (NoteDbHelper.class){
                mNoteDbHelper =new NoteDbHelper(context);
            }
        }
        return mNoteDbHelper;
    }

    public void save(Note mNote){
        mNoteDb.save(mNote);
    }

    public ArrayList<Note> qurey(){
        return mNoteDb.query(Note.class);
    }



}
